/**
 * @description 初始化表，添加一些数据
 */

import { UserModel,IUserInstance,roleType,IUserBase } from "./user";
import { ScriptModel } from "./scriptList";
import { GameModel } from "./game"
import { seq } from "../db";
import { Bcrypt } from "../utils/bcryptjs"
// 创建users目标
let users = [
    {
        userName: "nxp001",
        password: Bcrypt.hashStr("111111"),
        nickname: "牛小排",
        avatar:"http://47.93.221.158/001/牛小排.jpg",
        sex:true,
        isDM: true,
        role: roleType.BOSS
    },
    {
        userName: "ws001",
        password: Bcrypt.hashStr("111111"),
        nickname: "大酒神",
        avatar:"http://47.93.221.158/001/09.jpg",
        sex:true,
        isDM: true,
        role: roleType.BOSS
    },
    {
        userName: "qiutu",
        password: Bcrypt.hashStr("111111"),
        nickname: "囚徒",
        avatar:"http://47.93.221.158/001/囚徒.jpg",
        sex:true,
        isDM: true,
        role: roleType.BOSS
    },
    {
        userName: "dishi",
        password: Bcrypt.hashStr("111111"),
        nickname: "帝师",
        avatar:"http://47.93.221.158/001/帝师.jpeg",
        sex:true,
        isDM: true,
        role: roleType.BOSS
    }
]
//向users表中添加数据

let a = 
{
    "name":123
}

let scripts = [
    {
        scriptName: "第一天",  //剧本名字
        manNum: 2 ,  //剧本男性数量
        womenNum: 1 , //剧本女性数量
        introduction: "第一天加油" ,   //剧本简介
        cover:"封面.jpg" ,//剧本封面
        clue:{
            "第一章":{"钢笔.png":"","橡皮.png":"","铅笔.png":""}
            ,
            "第二章":{"动画.png":"","风和日丽.png":"","维尼.png":"","小卡片.png":""}
            ,
            "第三章":{"风景.png":"","哈尔滨.png":""}
            
        } ,//线索
        role:{ //jpg
            陈国汉:{
                name:"陈国汉",
                script:4,//剧本图片
                player:{
                    id:"",
                    nickname:"",
                    avatar:"",
                },
            },
            加藤鹰: {
                name:"加藤鹰",
                script:1,//剧本图片
                player:{
                    id:"",
                    nickname:"",
                    avatar:"",
                }
            },
            罗宾汉:{
                name:"罗宾汉",
                script:3,//剧本图片
                player:{
                    id:"",
                    nickname:"",
                    avatar:"",
                }
        }, //角色
       
            }
    }
]

let games = [
    {
        DM_nickname:"牛小排22",
        DM_id:100,
        scriptName:"第一天22",
        scriptId:100,
        role:JSON.stringify({}),
        isOver:false,
        is_deleted: false
    }
]

const init = async () => {
    try {
        await seq.sync({ force: true });
        console.log("同步结束");
        await UserModel.bulkCreate(users)
        await ScriptModel.bulkCreate(scripts);
        await GameModel.bulkCreate(games);
        // await GameModel.create(games[0]);
    } catch (err) {
        console.log("err", err);

    }

}

init()